<%--
  Created by IntelliJ IDEA.
  User: 乐乐
  Date: 2021/7/10
  Time: 17:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <%String path =request.getContextPath();%>
    <title>Title</title>
    <script type="text/javascript" src="<%=path%>/js/ckeditor/ckeditor.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=path%>/js/ckeditor/contents.css">
    <script type="text/javascript" src="<%=path%>/js/jquery-2.1.1.min.js"></script>
    <script>
        $(function (){
            CKEDITOR.replace("pname")
        })
        function getInfo2(){
             // var context =  CKEDITOR.instances.pname.getData();
             //    $("[name=pname]").val(context);
            $.ajax({
                url:"<%=path%>/to/insertAll",
                type:"get",
                data:$("#forminsert").serialize(),
                dataType:"text",
                async:true,
                success:function(result){
                    if(result){
                        alert("增加成功")
                        location.href="<%=path%>/to/toShow"
                    }
                },
                error:function(result){
                    alert("网路异常,请刷新");
                    console.log(result);
                }
            })
        }
    </script>
</head>
<body>
${list}
${list[0].tid}
${list[0].ttype}
<form id="forminsert">
    手机名称:<<textarea name="pname"></textarea>
    手机价格:<input type="text" name="pprice"><br>
    手机分类:<select name="ptype">
    <c:forEach items="${list}" var="l">
        <option value="${l.tid}">${l.ttype}</option>
    </c:forEach>
</select><br>
    上架时间:<input type="date" name="newsTime">
    <input type="button" value="增加" onclick="getInfo2()" >
</form>
</body>
</html>
